package pl.cezary.butler.walili.client;

import pl.cezary.butler.walili.client.gui.GUI;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class ClientApp {

    private static final Logger log = java.util.logging.Logger.getLogger(ClientApp.class.getName());
    private static ApplicationContext context;

    public static ApplicationContext initSpringContext() {
        if (context == null) {
            context = DownloaderApp.getContext();
            if (context == null) {
                try {
                    context = new ClassPathXmlApplicationContext(ClientApp.class.getPackage().getName().replace('.', '/') + "/client.xml");
                } catch (BeansException ex) {
                    log.log(Level.SEVERE, "Pobranie kontekstu spring nie powiodło się", ex);
                    throw new RuntimeException(ex);
                }
            }
        }
        return context;
    }

    public static ApplicationContext getContext() {
        return context;
    }

    public static void main(String[] args) {

        
        GUI g = new GUI();
        LoginControler klog = new LoginControler();
        klog.connectDataSource(g);
        return;
    }
}
